package test.client;

import java.util.concurrent.atomic.AtomicInteger;
import org.je.log.JLog;
import com.fyf.game.net.ReceiveHandler;
import com.fyf.game.net.Sender;
import com.fyf.game.net.client.MessageChannel;

/**
 * @author fanyifeng
 */
public class Ts
{
	static AtomicInteger	count	= new AtomicInteger(0);
	static long				t		= System.nanoTime();

	public static void main(String[] args) {

		MessageChannel channel = new MessageChannel(new ReceiveHandler() {

			public void onReceive(String msg, Sender sender) {
				int c = count.incrementAndGet();
				if (c % 1000 == 0) {
					JLog.out(msg + " : " + c + " : " + (System.nanoTime() - t) / 1000000);
				}
			}
		});

		channel.connect("127.0.0.1", 9999);

		for (int i = 0; i < 9999; ++i) {
			channel.send("im ok " + i);
		}

		channel.outLine();
	}
}
